﻿
@{
    ViewBag.Title = "UpdateCarAudit";
    ViewBag.First = "车辆管理";
    ViewBag.Second = "修改车辆审核";
    Layout = "~/Views/Shared/_BaseLayout.cshtml";
    var ent = ViewData["ent"] as Sc.Domain.CarAudit;
    var list = ViewData["olist"] as IList<Sc.Domain.CommOrgz>;
    var typelist = ViewData["type"] as IList<Sc.Domain.BaseItem>;
}
<script src="~/Content/laydate-v1.1/laydate/laydate.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        initSingleDate("txtAuditDate", "YYYY/MM/DD");

        $(".select2").uedSelect({
            width: 247
        });
    });
    //车辆选择
    function selectCar() {
        layer.open({
            type: 2,
            title: "审核车辆选择",
            shade: [0],
            area: [($(window).width() - 20) + "px", ($(window).height() - 80) + "px"],
            content: ['@Url.Action("SelectCarInfo", "CarInfo")', 'yes']
        });
    }
    //车辆选择确认
    function sureCarInfo(id, carNo) {
        var car = $("#txtCar");
        car.val(carNo); car.attr("carId", id);
        layer.closeAll();
    }
    //数据保存
    function saveData(tag) {
        var txtCar = $("#txtCar").val();
        var txtBaseItem = $("#selBaseItem").val();
        var txtAuditDate = $("#txtAuditDate").val();
        var txtAuditYear = $("#txtAuditYear").val();
        var selOrgz = $("#selOrgz").val();
        var txtReson = $("#txtReson").val();
        if (txtCar.length <= 0) {
            Tips("请选择要审核的车辆", "txtCar");
            return false;
        }
        if (txtBaseItem.length <= 0) {
            Tips("请选择审核类型", "txtBaseItem");
            return false;
        }
        if (txtAuditDate.length <= 0) {
            Tips("请选择审核时间", "txtAuditDate");
            return false;
        }
        if (selOrgz.length <= 0) {
            Tips("请选择审核单位", "selOrgz");
            return false;
        }
        if (txtAuditYear.length <= 0) {
            Tips("请输入审核年限", "txtAuditYear");
            return false;
        }
        if (isNaN(txtAuditYear)) {
            Tips("审核年限只能为数字", "txtAuditYear");
            return false;
        }
        var ent = new Object();
        ent.CarId = $("#txtCar").attr("carId");
        ent.BaseItemId = txtBaseItem;
        ent.AuditDate = txtAuditDate;
        ent.AuditYear = txtAuditYear;
        ent.OrgzNo = selOrgz;
        ent.Remark = txtReson;
        ent.Id = '@ent.Id';

        var url = "@Url.Action("SaveCarAudit")";
        var load = loadTip("数据提交中，请稍候", 16, 0);
        $.post(url, { data: JSON.stringify(ent)}, function (data) {
            if (data > 0) {
                if (tag == 1) {
                    layer.msg("数据保存成功", { icon: 1, time: 1000, shade: [0.3, '#000'] }, function () {
                        document.getElementById("formData").reset();
                    });
                } else {
                    layer.msg("数据保存成功", { icon: 1, time: 1000, shade: [0.3, '#000'] }, function () {
                        back();
                    });
                }
            }
        });
    }
    function back() {
        window.location.href = "@Url.Action("Index")";
    }

</script>
<div class="formbody">
    <div class="formtitle"><span>修改车辆报废</span></div>
    <form method="post" enctype="multipart/form-data" class="jqtransform" id="formData" style="margin-top:-20px;">
        <table style="width:98%;margin-left:20px;line-height:48px;">
            <tr>
                <td><label>审核车辆</label></td>
                <td colspan="3">
                    <input type="text" readonly="readonly" class="dfinput" id="txtCar" value="@ent.CarNo" carId="@ent.CarId" />
                    <input type="button" class="scbtn" onclick="selectCar();" value="选择" />
                </td>

            </tr>
            <tr>
                <td><label>审核类型</label></td>
                <td>
                    <select name="select" class="select2" id="selBaseItem">
                        <option value="0">----请选择----</option>
                        @foreach (var item in typelist)
                        {
                            <option @(ent.BaseItemId == item.Id ? "selected" : "") value="@item.Id">@item.Name</option>
                        }
                    </select>
                </td>
                <td><label>审核时间</label></td>
                <td><input type="text" class="dfinput" id="txtAuditDate" value="@ent.AuditDate.ToString("yyyy/MM/dd")" /></td>

            </tr>
            <tr>
                <td><label>审核年限</label></td>
                <td><input type="text" class="dfinput" id="txtAuditYear" value="@ent.AuditYear" /> 年</td>
                <td><label>审核单位</label></td>
                <td>
                    <select name="select" class="select2" id="selOrgz">
                        <option value="0">----请选择----</option>
                        @foreach (var item in list)
                        {
                            <option @(ent.OrgzNo == item.Id ? "selected" : "") value="@item.Id">@item.OrgzName</option>
                        }
                    </select>
                </td>
            </tr>
            <tr>
                <td><label>备注</label></td>
                <td colspan="3">
                    <input type="text" class="dfinput" id="txtReson" value="@ent.Remark" />
                </td>
            </tr>
        </table>

        <input type="file" onchange="fileUpload()" style="display:none" name="fl" id="fl" />
        <input type="button" class="scbtn" onclick="saveData(2);" value="保 存" />
        <input type="button" class="scbtn" onclick="back();" value="返 回" />
    </form>
</div>

